package demo.platform;

import java.awt.Rectangle;
import java.awt.event.KeyEvent;


public class Player extends Entity{

	Rectangle[] collisions;

	public Player() {
		initEntity();
		
	}
	
	public void initEntity() {
		setSpritePath("res/Sprites/Pinky/pinky_64_64.png");
		loadSpriteImage();
		setJumping(false);
		setEntityDeath(false);
		initCollisions();
		setX(256);
		setY(19*32);
		
	}
	
	public void keyPressed(KeyEvent e) {
		int key = e.getKeyCode();
		
		if (key == KeyEvent.VK_UP) {
			//jump();
			setDirection(1);
			setDY(-1);
			
		}
		
		if (key == KeyEvent.VK_DOWN) {
			//isFalling = true;
			setDirection(3);
			setDY(1);
		}
		
		if (key == KeyEvent.VK_RIGHT) {
			setDirection(2);
			setDX(1);
			
			//x_position += dx;
		}
		
		if (key == KeyEvent.VK_LEFT) {
			setDirection(4);
			setDX(-1);
			
		}
		
		if (key == KeyEvent.VK_R) {
			setX(256);
			
			
		}
		
	}
	
	public void keyReleased(KeyEvent e) {
		int key = e.getKeyCode();
		
		if (key == KeyEvent.VK_LEFT | key == KeyEvent.VK_RIGHT) {
			setDX(0);
		}
		
		if (key == KeyEvent.VK_UP | key == KeyEvent.VK_DOWN) {
			setDY(0);
		}
	}
	
	// Test
	
	public void setCollisions(Rectangle[] r) {
		collisions = r;
	}
	
	public Rectangle[] getCollisions() {
		return collisions;
	}
	
}
